/**
 * Copyright 2014 the original author or authors. All rights reserved.
 */
package com.visionet.security.filter;

import java.io.IOException;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.visionet.jumper.core.common.Message;
import com.visionet.security.base.enums.SecurityMessage;
import com.visionet.security.utils.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 *
 * @author suxiaojing
 * @date 
 * @since 0.0.1
 */
public class RestPermissionsAuthorizationFilter extends DynamicPermissionsAuthorizationFilter {
	
	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.apache.shiro.web.filter.authz.AuthorizationFilter#onAccessDenied(
	 * javax.servlet.ServletRequest, javax.servlet.ServletResponse)
	 */
	@Override
	protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws IOException {
		logger.trace("Attempting to access a path which was forbidden.");
		Message loginMsg = new Message(SecurityMessage.ACCESS_DENY.getCode(), SecurityMessage.ACCESS_DENY.getValue());
		WebUtils.writeJsonResponse(loginMsg, WebUtils.toHttp(response));
		return false;
	}

}
